import java.math.BigDecimal;
import java.util.*;

class TreeNode{
    int val;
    TreeNode right=null,left=null;

    public TreeNode(int val) {
        this.val = val;
    }
}
public class TreeDemo {
    public static void main(String[] args) {
        HashMap<Integer,String> hashMap = new HashMap<>();
        hashMap.put(3,"djfkslf");
        Iterator<Integer> iterator = hashMap.keySet().iterator();
        while (iterator.hasNext()){
            Integer next = iterator.next();
        }
        String str = "123456789";
        String str1 = new String("123456789");
        String str2 = str.intern();
        System.out.println("str2 = " + str2);
        System.out.println(str2==str);
        System.out.println(str1==str);
        TreeNode pRoot = new TreeNode(1);
        TreeNode pRoot1 = new TreeNode(2);
        TreeNode pRoot2 = new TreeNode(2);
        TreeNode pRoot3 = new TreeNode(3);
        TreeNode pRoot4 = new TreeNode(4);
        TreeNode pRoot5 = new TreeNode(4);
        TreeNode pRoot6 = new TreeNode(3);
        pRoot.left = pRoot1;
        pRoot1.right = pRoot4;
        pRoot1.left = pRoot3;
        pRoot.right = pRoot2;
        pRoot2.left = pRoot5;
        pRoot2.right = pRoot6;
//        boolean res = isSymmetrical(pRoot);
//        int res = maxDepth(pRoot);
//        System.out.println("res = " + res);
    }



    private static int maxDepth(TreeNode pRoot) {
        if (pRoot==null) return 0;
        Queue<TreeNode> q1 = new LinkedList<>();
        q1.offer(pRoot);
        int res = 0;
        while (!q1.isEmpty()){
            int n = q1.size();
            for (int i = 0; i < n; i++) {
                TreeNode node = q1.poll();
                if(node.left!=null) q1.offer(node.left);
                if(node.right!=null) q1.offer(node.right);
            }
            res++;
        }
        return res;
    }

    private static boolean isSymmetrical(TreeNode pRoot) {
        Queue<TreeNode> q1 = new LinkedList<>();
        Queue<TreeNode> q2 = new LinkedList<>();
        if (pRoot == null || (pRoot.left==null && pRoot.right == null)) return true;
        q1.offer(pRoot.left);
        q2.offer(pRoot.right);
        while (!q1.isEmpty()&&!q2.isEmpty()){
            TreeNode left = q1.poll();
            TreeNode right = q2.poll();
            if (left==null && right == null){
                continue;
            }
            if (left == null || right == null || left.val != right.val){
                return false;
            }
            // 左边
            q1.offer(left.left);
            q1.offer(left.right);
            // 右边
            q2.offer(right.right);
            q2.offer(right.left);
        }
        return true;
    }
}
